#include "TileMessage.h"


TileMessage::TileMessage( MessageType _type, BYTE* _buffer /*= NULL*/ )
	:PipeMessage( _type)
{
	if( _buffer)
	{
		mBuffer = _buffer;
		ParseBuffer();
	}
}

UINT TileMessage::CreateBuffer( UINT _startPos /*= 0*/ )
{
	memcpy_s(mBuffer + _startPos, sizeof(mData), &mData, sizeof(mData));
	_startPos +=  sizeof(mData);

	return _startPos;
}

void TileMessage::ParseBuffer()
{
	memcpy_s(&mData, sizeof(mData), mBuffer + sizeof(MessageType),  sizeof(mData));
}


void TileMessage::SetData( UINT _line, UINT _col, char _letter/*=' '*/ )
{
	mData.tileLine = _line;
	mData.tileCol = _col;
	mData.letter = _letter;

	mBufferChanged = true;
}

UINT TileMessage::GetBufferSize()
{
	return sizeof(mData);
}
